package com.eriloan.easyPage.plugins.spring;

import javax.servlet.ServletContext;

import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

import com.eriloan.easyPage.util.EasyPageContext;

/**
 * 
 * <p>Copyright: All Rights Reserved</p>
 * <p>Company: 北京荣之联科技股份有限公司 http://www.ronglian.com</p>
 * <p>Description: Spring 处理类</p>
 * <p>Author:Eric Shi/史丙利</p>
 */
public class SpringBeansManagement{
	
	/**
	 * 
	 * <br/>Description:返回Spring托管的Bean
	 * <p>Author:Eric Shi/史丙利</p>
	 * @param clazz
	 * @return
	 */
	public <T> T getSrpingBean(Class<T> clazz){
		EasyPageContext easyPageContext=new EasyPageContext();
		
		ServletContext servletContext = easyPageContext.getServletContext();
		WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);
		T t=wac.getBean(clazz);
		return t;
	}
}
